<template>
    <el-dialog v-model="$store.state.HomeMoudule.dialogFormVisible" title="请输入修改信息">
        <el-form :model="store.state.HomeMoudule.uplistData">
            <el-form-item label="户主" :label-width="formLabelWidth">
                <el-input v-model="store.state.HomeMoudule.uplistData.name" autocomplete="off" id="inputId" />
            </el-form-item>
            <el-form-item label="楼盘名称" :label-width="formLabelWidth">
                <el-input v-model="store.state.HomeMoudule.uplistData.title" autocomplete="off" id="inputTitle" />
            </el-form-item>
            <el-form-item label="房源类型" :label-width="formLabelWidth">
                <el-input v-model="store.state.HomeMoudule.uplistData.type" autocomplete="off" id="inputType" />
            </el-form-item>
            <el-form-item label="房源类型" :label-width="formLabelWidth">
                <el-input v-model="store.state.HomeMoudule.uplistData.hometype" autocomplete="off" id="inputHometype" />
            </el-form-item>
            <el-form-item label="门牌号" :label-width="formLabelWidth">
                <el-input v-model="store.state.HomeMoudule.uplistData.num" autocomplete="off" id="inputNum" />
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="closeDialog(0)">取消</el-button>
                <el-button type="primary" @click="closeDialog(1)">
                    确定
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script lang="ts" setup>
import { onBeforeMount, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useStore } from "vuex";
import Link from "../api/Link.js";
import apiurl from "../api/url.js";

const dialogFormVisible = ref(false)
const formLabelWidth = '140px'
let store = useStore()

let closeDialog = async (numb: number) => {
    store.commit("DIALOG")
    if (numb == 1) {
        console.log(store.state.HomeMoudule.uplistData)
        await Link(apiurl.userlist + "/" + store.state.HomeMoudule.uplistData.id,
            "PUT",
            { name: store.state.HomeMoudule.uplistData.name, title: store.state.HomeMoudule.uplistData.title, type: store.state.HomeMoudule.uplistData.type, hometype: store.state.HomeMoudule.uplistData.hometype, num: store.state.HomeMoudule.uplistData.num })
            .then((ok: any) => {
                console.log(ok)
            })
    }
    store.dispatch("USERUPDATA_LIST")
}

</script>

<style scoped>
.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>